package com.axjy.controller;

import com.axjy.pojo.Provider;
import com.axjy.service.ProviderService;
import com.mysql.jdbc.StringUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by Administrator on 2017/12/26.
 */
@WebServlet("/searchProvider.action")
public class SearchProviderAction extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String proname=req.getParameter("proname");
        List<Provider> list=null;
        ProviderService providerService=new ProviderService();
        if(StringUtils.isNullOrEmpty(proname)){
            list=providerService.searchAll();
        }else{
            list=providerService.search(proname);
        }
        req.setAttribute("list",list);
        req.getRequestDispatcher("/searchProvider.jsp").forward(req,resp);
    }
}
